'use strict'

const Service = require('egg').Service

class FeedbackService extends Service {
  // 添加/删除反馈
  async addOrDelFeedback(where) {
    const { app } = this
    // 1.是否反馈过
    const result = await app.model.Feedback.findOne({ where })
    if (result) {
      await app.model.Feedback.destroy({ where: { id: result.id } })
      return '删除反馈成功！'
    } else {
      return await app.model.Feedback.create(where)
    }
  }
}

module.exports = FeedbackService
